<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import systemDeptInfo from '@/api/system/systemDeptInfo'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  systemDeptInfo.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  systemDeptInfo.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_system_dept_info',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: systemDeptInfo.getList,
  recycleApi: systemDeptInfo.getRecycleList,
  add: {
    show: true,
    api: systemDeptInfo.save,
    auth: ['system:deptInfo:save']
  },
  edit: {
    show: true,
    api: systemDeptInfo.update,
    auth: ['system:deptInfo:update']
  },
  delete: {
    show: true,
    api: systemDeptInfo.deletes,
    auth: ['system:deptInfo:delete'],
    realApi: systemDeptInfo.realDeletes,
    realAuth: ['system:deptInfo:realDeletes']
  },
  recovery: {
    show: true,
    api: systemDeptInfo.recoverys,
    auth: ['system:deptInfo:recovery']
  },
  import: {
    show: true,
    url: 'system/deptInfo/import',
    templateUrl: 'system/deptInfo/downloadTemplate',
    auth: ['system:deptInfo:import']
  },
  export: {
    show: true,
    url: 'system/deptInfo/export',
    auth: ['system:deptInfo:export']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "",
    dataIndex: "dept_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "企业名称",
    dataIndex: "companyName",
    formType: "input",
    search: true
  },
  {
    title: "公司类型",
    dataIndex: "companyType",
    formType: "input",
    search: true
  },
  {
    title: "法人",
    dataIndex: "legalPerson",
    formType: "input",
    search: true
  },
  {
    title: "注册资本",
    dataIndex: "capital",
    formType: "input",
    search: true
  },
  {
    title: "注册号",
    dataIndex: "companyCode",
    formType: "input",
    search: true
  },
  {
    title: "统一社会信用代码",
    dataIndex: "creditNo",
    formType: "input",
    search: true
  },
  {
    title: "经营范围",
    dataIndex: "businessScope",
    formType: "input",
    search: true
  },
  {
    title: "登记机关",
    dataIndex: "authority",
    formType: "input",
    search: true
  },
  {
    title: "经营状态",
    dataIndex: "companyStatus",
    formType: "input",
    search: true
  },
  {
    title: "成立日期",
    dataIndex: "establishDate",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "营业期限开始时间",
    dataIndex: "operationStartdate",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "营业期限结束时间",
    dataIndex: "operationEnddate",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "核准日期",
    dataIndex: "issueDate",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "注册地址",
    dataIndex: "companyAddress",
    formType: "input",
    search: true
  },
  {
    title: "行业",
    dataIndex: "industry",
    formType: "input",
    search: true
  },
  {
    title: "法人类型",
    dataIndex: "legalPersonType",
    formType: "input",
    search: true
  },
  {
    title: "曾用名",
    dataIndex: "historyNames",
    formType: "input",
    search: true
  },
  {
    title: "更新时间",
    dataIndex: "lastUpdatedTime",
    formType: "date",
    search: true,
    showTime: true
  },
  {
    title: "实收注册资金",
    dataIndex: "realCapital",
    formType: "input",
    search: true
  },
  {
    title: "组织机构代码",
    dataIndex: "orgCode",
    formType: "input",
    search: true
  },
  {
    title: "省份",
    dataIndex: "province",
    formType: "input",
    search: true
  },
  {
    title: "省份行政区号",
    dataIndex: "provinceCode",
    formType: "input",
    search: true
  },
  {
    title: "地市",
    dataIndex: "city",
    formType: "input",
    search: true
  },
  {
    title: "地市行政区号",
    dataIndex: "cityCode",
    formType: "input",
    search: true
  },
  {
    title: "地区",
    dataIndex: "district",
    formType: "input",
    search: true
  },
  {
    title: "地区行政区号",
    dataIndex: "districtCode",
    formType: "input",
    search: true
  },
  {
    title: "电话号码",
    dataIndex: "phoneNumber",
    formType: "input",
    search: true
  },
  {
    title: "电话备注",
    dataIndex: "phoneNumber_note",
    formType: "input",
    search: true
  },
  {
    title: "邮箱",
    dataIndex: "email",
    formType: "input",
    search: true
  },
  {
    title: "邮箱备注",
    dataIndex: "email_note",
    formType: "input",
    search: true
  },
  {
    title: "地址",
    dataIndex: "address",
    formType: "input",
    search: true
  },
  {
    title: "地址备注",
    dataIndex: "address_note",
    formType: "input",
    search: true
  },
  {
    title: "网址",
    dataIndex: "website",
    formType: "input",
    search: true
  },
  {
    title: "网址备注",
    dataIndex: "website_note",
    formType: "input",
    search: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "修改时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "修改者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'system:deptInfo' } </script>